#include "supports.h"
#include "ch32v30x_libs.h"
#include "FreeRTOS.h"
#include "task.h"

void GPIO_boardInit(){
    GPIO_InitTypeDef GPIO_InitStructure = {0};

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA,&GPIO_InitStructure);
}

TaskHandle_t task1_handler;

void task1_task(void *pvParameters){
    while (1){
        GPIO_WriteBit(GPIOA,GPIO_Pin_15,Bit_RESET);
        vTaskDelay(100);
        GPIO_WriteBit(GPIOA,GPIO_Pin_15,Bit_SET);
        vTaskDelay(100);
    }
}

extern "C"
int main(void){
    GPIO_boardInit();
    
    xTaskCreate(task1_task,
                (const char*)"task1",
                (uint16_t)256,
                (void*)NULL,
                (UBaseType_t)5,
                (TaskHandle_t *)&task1_handler);
    
    /* 启动线程调度 */
    vTaskStartScheduler();
    while ( true ){
        
    }
}